package com.ruoyi.project.basic.inventoryclass.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.basic.inventoryclass.domain.JcInventoryclass;
import com.ruoyi.project.basic.inventoryclass.service.IJcInventoryclassService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 存货分类Controller
 * 
 * @author frank
 * @date 2024-08-24
 */
@RestController
@RequestMapping("/basic/inventoryclass/inventoryclass")
public class JcInventoryclassController extends BaseController
{
    @Autowired
    private IJcInventoryclassService jcInventoryclassService;

    /**
     * 查询存货分类列表
     */
    @PreAuthorize("@ss.hasPermi('basic/inventoryclass:inventoryclass:list')")
    @GetMapping("/list")
    public TableDataInfo list(JcInventoryclass jcInventoryclass)
    {
        startPage();
        List<JcInventoryclass> list = jcInventoryclassService.selectJcInventoryclassList(jcInventoryclass);
        return getDataTable(list);
    }

    /**
     * 导出存货分类列表
     */
    @PreAuthorize("@ss.hasPermi('basic/inventoryclass:inventoryclass:export')")
    @Log(title = "存货分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JcInventoryclass jcInventoryclass)
    {
        List<JcInventoryclass> list = jcInventoryclassService.selectJcInventoryclassList(jcInventoryclass);
        ExcelUtil<JcInventoryclass> util = new ExcelUtil<JcInventoryclass>(JcInventoryclass.class);
        util.exportExcel(response, list, "存货分类数据");
    }

    /**
     * 获取存货分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic/inventoryclass:inventoryclass:query')")
    @GetMapping(value = "/{jcInventoryclassoid}")
    public AjaxResult getInfo(@PathVariable("jcInventoryclassoid") String jcInventoryclassoid)
    {
        return success(jcInventoryclassService.selectJcInventoryclassByJcInventoryclassoid(jcInventoryclassoid));
    }

    /**
     * 新增存货分类
     */
    @PreAuthorize("@ss.hasPermi('basic/inventoryclass:inventoryclass:add')")
    @Log(title = "存货分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JcInventoryclass jcInventoryclass)
    {
        return toAjax(jcInventoryclassService.insertJcInventoryclass(jcInventoryclass));
    }

    /**
     * 修改存货分类
     */
    @PreAuthorize("@ss.hasPermi('basic/inventoryclass:inventoryclass:edit')")
    @Log(title = "存货分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JcInventoryclass jcInventoryclass)
    {
        return toAjax(jcInventoryclassService.updateJcInventoryclass(jcInventoryclass));
    }

    /**
     * 删除存货分类
     */
    @PreAuthorize("@ss.hasPermi('basic/inventoryclass:inventoryclass:remove')")
    @Log(title = "存货分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{jcInventoryclassoids}")
    public AjaxResult remove(@PathVariable String[] jcInventoryclassoids)
    {
        return toAjax(jcInventoryclassService.deleteJcInventoryclassByJcInventoryclassoids(jcInventoryclassoids));
    }
}
